//
//  YWLittleWindowVedioView.m
//  videoTest3
//
//  Created by jun peng on 2022/7/3.
//

#import "YWLittleWindowVedioView.h"
#import <TXLiteAVSDK_Player/TXLiteAVSDK.h>

@implementation YWLittleWindowVedioView

-(void)awakeFromNib{
    [super awakeFromNib];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(enterBackground) name:YWEnterBackgroundNote object:nil];
    
}

-(void)dealloc{
    
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
-(void)enterBackground{
    
    [self pausePlay];
    
}
-(void)pausePlay{
    YWVideoPlayerManager *playerManager = [YWVideoPlayerManager sharevideoPlayerManager];
    [playerManager pausePlayWithComplication:^{
        
    }];
}

//创建videoPlayView
+ (instancetype)videoView{
    
    return [[[NSBundle mainBundle] loadNibNamed:@"YWLittleWindowVedioView" owner:nil options:nil] firstObject];
}

//开始
-(void)startPlayWithUrl:(NSString *)urlString withMute:(BOOL)mute{
    
    YWVideoPlayerManager *playerManager = [YWVideoPlayerManager sharevideoPlayerManager];
  
      [playerManager startPlayWithUrl:urlString view:self complication:^{
          
          [playerManager setMute:mute];
  
      } startPlay:^{
          
      } progress:^(float progress, float duration, float playable) {
  
      } end:^{
  
      } loading:^{
        
      }];
    
}


-(void)continuePlayWithAnthorViewWithUrl:(NSString *)urlString WithMute:(BOOL)mute{
    
    YWVideoPlayerManager *playerManager = [YWVideoPlayerManager sharevideoPlayerManager];
    
    //继续播放
    [playerManager continuePlayWithComplication:^{
    
    }];
    
    [playerManager continuePlayWithAnthorView:self complication:^{
        
        [playerManager setMute:mute];
    } startPlay:^{
    
    } progress:^(float progress, float duration, float playable) {
      
    } end:^{
        
    } loading:^{
       
    }];
    
}

@end
